<?php

class Site_hooks {
	private $ci;
	
	function __construct() 
	{
		$this->ci =& get_instance();	
		
	}	
	
	
	
	public function get_hooks($hookPoint)
	{
		//$this->ci->load->view('gen_output', array('output' => 'iPageId: '.$this->ci->iPageId.'<hr />'));
	
		$this->ci->load->model('db/views/hooks_libs_methods', 'vw_hooks_libs_methods');
		
		$this->ci->vw_hooks_libs_methods->page_id = $this->ci->iPageId;
		$this->ci->vw_hooks_libs_methods->method_point = $hookPoint;
		$this->ci->vw_hooks_libs_methods->method_active = 'Y';
		
		$aOptions = array(
					'order_by' => array(
								'lib_pos' => 'ASC',
								'method_pos' => 'ASC'
					)
		);
		
		$qHooks = $this->ci->vw_hooks_libs_methods->get($aOptions);
		
		$iHooks = $qHooks->num_rows();
		
		for ($i = 0; $i < $iHooks; $i++)
		{
			$sClass = $qHooks->row($i)->lib_class;
			$sMethod = $qHooks->row($i)->method_func;
			
			$this->ci->load->library('hooks/'.$sClass, $sClass);
			
			$this->ci->$sClass->$sMethod();
		}
			
	}
}

?>